package com.dsl.tms.controller;

import com.dsl.tms.entity.response.IfSucessMap;
import com.dsl.tms.entity.response.ListMap;
import com.dsl.tms.service.AppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@RefreshScope
@RestController
@CrossOrigin("http://localhost:8080")
public class AppController {

    @Autowired
    private AppService appService;

    @RequestMapping(path = "/save_error_logger",method = RequestMethod.POST)
    public String save_error_logger(@RequestBody com.dsl.tms.entity.request.ErrorLogger errorLogger){
        IfSucessMap ifSucessMap =  appService.save_error_logger(errorLogger,errorLogger.getToken());
        return ifSucessMap.getResult().getDescription();
    }

    @RequestMapping(path = "get_error_list",method = RequestMethod.GET)
    public ListMap get_error_list(@RequestParam("token") String token){
        return appService.get_error_list(token);
    }

}
